/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.trainning.giangnd.btvn2;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 *
 * @author GIANG
 */
public class B8 {
    public static void main(String[] args) throws FileNotFoundException, IOException {
        BufferedReader br = new BufferedReader(new FileReader("Data/B8.txt"));
        BufferedWriter bf = new BufferedWriter(new FileWriter("Data/B8OUT.txt"))
            String s = br.readLine();
            System.out.println("Xâu của bạn là " + s);
            StringTokenizer s1 = new StringTokenizer(s);
            String a[] = new String[100];
            int n=0;
            while (s1.hasMoreTokens())
                a[n++] = s1.nextToken();
            for(int i=0;i<n;i++)
                for(int j=n-1;j>i;j--)
                    if (a[i].compareTo(a[j])>0) {
                        String tmp;
                        tmp=a[i];
                        a[i]=a[j];
                        a[j]=tmp;
                    }
            System.out.println("Sau khi sap xep:");
            bf.write("Sau khi xep:");
            bf.newLine();
            for(int i=1;i<n;i++){
                System.out.print(a[i]+" ");
                bf.write(a[i]+" ");
            }
            bf.close();
        }
}
